package com.mercury.emqx.client.req;

import com.alibaba.fastjson.annotation.JSONField;
import com.mercury.emqx.model.PayloadMessage;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author mercury
 */
@Data
@NoArgsConstructor
public class MqttSubscribeReq {

    private String topic;
    private String topics;
    @JSONField(
            name = "clientid"
    )
    private String clientId;
    private Integer qos = 2;



    public MqttSubscribeReq(PayloadMessage message) {
        if (Objects.isNull(message)){
            return;
        }
        this.topic = message.getTopic();
        this.topics = message.getTopics();
        this.clientId = message.getClientId();
        this.qos = message.getQos();
    }
}
